package com.example.mapper.Dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.session.ResultHandler;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

abstract public class BaseDao<D, M extends BaseMapper<D>> implements BaseMapper<D> {

    abstract protected BaseMapper<D> getMapper();

    @Override
    public int insert(D entity) {
        return this.getMapper().insert(entity);
    }

    @Override
    public int deleteById(Serializable id) {
        return this.getMapper().deleteById(id);
    }

    @Override
    public int deleteById(D entity) {
        return 0;
    }

    @Override
    public int deleteByMap(Map<String, Object> columnMap) {
        return this.getMapper().deleteByMap(columnMap);
    }

    @Override
    public int delete(Wrapper<D> wrapper) {
        return this.getMapper().delete(wrapper);
    }

    @Override
    public int deleteBatchIds(Collection<?> idList) {
        return 0;
    }


    @Override
    public int updateById(D entity) {
        return this.getMapper().updateById(entity);
    }

    @Override
    public int update(D entity, Wrapper<D> updateWrapper) {
        return this.getMapper().update(entity, updateWrapper);
    }

    @Override
    public int update(Wrapper<D> updateWrapper) {
        return BaseMapper.super.update(updateWrapper);
    }

    @Override
    public D selectById(Serializable id) {
        return this.getMapper().selectById(id);
    }

    @Override
    public List<D> selectBatchIds(Collection<? extends Serializable> idList) {
        return this.getMapper().selectBatchIds(idList);
    }

    @Override
    public void selectBatchIds(Collection<? extends Serializable> idList, ResultHandler<D> resultHandler) {

    }

    @Override
    public List<D> selectByMap(Map<String, Object> columnMap) {
        return this.getMapper().selectByMap(columnMap);
    }

    @Override
    public void selectByMap(Map<String, Object> columnMap, ResultHandler<D> resultHandler) {
        BaseMapper.super.selectByMap(columnMap, resultHandler);
    }

    @Override
    public D selectOne(Wrapper<D> queryWrapper) {
        return this.getMapper().selectOne(queryWrapper);
    }

    @Override
    public D selectOne(Wrapper<D> queryWrapper, boolean throwEx) {
        return this.getMapper().selectOne(queryWrapper, throwEx);
    }

    @Override
    public boolean exists(Wrapper<D> queryWrapper) {
        return this.getMapper().exists(queryWrapper);
    }

    @Override
    public Long selectCount(Wrapper<D> queryWrapper) {
        return this.getMapper().selectCount(queryWrapper);
    }

    @Override
    public List<D> selectList(Wrapper<D> queryWrapper) {
        return this.getMapper().selectList(queryWrapper);
    }

    @Override
    public void selectList(Wrapper<D> queryWrapper, ResultHandler<D> resultHandler) {
        this.getMapper().selectList(queryWrapper, resultHandler);
    }

    @Override
    public List<D> selectList(IPage<D> page, Wrapper<D> queryWrapper) {
        return this.getMapper().selectList(page, queryWrapper);
    }

    @Override
    public void selectList(IPage<D> page, Wrapper<D> queryWrapper, ResultHandler<D> resultHandler) {
        this.getMapper().selectList(page, queryWrapper, resultHandler);
    }

    @Override
    public List<Map<String, Object>> selectMaps(Wrapper<D> queryWrapper) {
        return this.getMapper().selectMaps(queryWrapper);
    }

    @Override
    public void selectMaps(Wrapper<D> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) {
        this.getMapper().selectMaps(queryWrapper, resultHandler);
    }

    @Override
    public List<Map<String, Object>> selectMaps(IPage<? extends Map<String, Object>> page, Wrapper<D> queryWrapper) {
        return this.getMapper().selectMaps(page, queryWrapper);
    }

    @Override
    public void selectMaps(IPage<? extends Map<String, Object>> page, Wrapper<D> queryWrapper, ResultHandler<Map<String, Object>> resultHandler) {
        this.getMapper().selectMaps(page, queryWrapper, resultHandler);
    }

    @Override
    public <E> List<E> selectObjs(Wrapper<D> queryWrapper) {
        return this.getMapper().selectObjs(queryWrapper);
    }

    @Override
    public <E> void selectObjs(Wrapper<D> queryWrapper, ResultHandler<E> resultHandler) {
        this.getMapper().selectObjs(queryWrapper, resultHandler);
    }

    @Override
    public <E extends IPage<D>> E selectPage(E page, Wrapper<D> queryWrapper) {
        return this.getMapper().selectPage(page, queryWrapper);
    }

    @Override
    public <E extends IPage<Map<String, Object>>> E selectMapsPage(E page, Wrapper<D> queryWrapper) {
        return this.getMapper().selectMapsPage(page, queryWrapper);
    }

}
